package com.yxw.yxnet_cd_center.common.exception;

import com.yxw.yxnet_cd_center.common.enums.CommonErrorEnum;
import lombok.Data;

/**
 * @desc:
 * @program: yxw1.0
 * @author: qlinc com.yxw.user.constant.exception.BaseException
 * @date: 2022-10-16 10:21:56
 */
@Data
public class BaseException extends RuntimeException {
    private static final long serialVersionUID = -4585733876707681692L;
    private String code;
    private String type;
    private String description;
    private String primaryErrorCode;
    private String primaryErrorMsg;
    private String primaryErrorIP;

    public BaseException() {
    }


    public BaseException(String code, String type, String description) {
        super(description);
        this.code = code;
        this.type = type;
        this.description = description;
    }

    public BaseException(CommonErrorEnum commonErrorEnum, String primaryErrorMsg) {
        super(commonErrorEnum.getDescription());
        this.code = commonErrorEnum.getCode();
        this.type = commonErrorEnum.getType();
        this.description = primaryErrorMsg;
        this.primaryErrorMsg = primaryErrorMsg;
    }

    public BaseException(CommonErrorEnum commonErrorEnum) {
        super(commonErrorEnum.getDescription());
        this.code = commonErrorEnum.getCode();
        this.type = commonErrorEnum.getType();
        this.description = commonErrorEnum.getDescription();
    }

    public BaseException(String errMsg) {
        super(errMsg);
        this.code = "201";
        this.type = "";
        this.description = errMsg;
    }
}

